
use "/Users/macbook/Desktop/Chronic disease/data& dofile/Share_data of patients.dta",clear
***Table 1 sample size
tab samplesize_h samplesize_d


***Table 2 Demographic and socio-economic characteristics of the participants
tokenize 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
foreach var of varlist gender gender_h gender_d age1 age1_h age1_d education education_h education_d health_sta health_sta_h health_sta_d poor_h poor_h_h poor_h_d{
logout, save(Table 2_`1') word replace:tab `var' 
macro shift
}

***Table 3 The regularity of hospital visits undertaken and the medication adherence of the participants
tokenize 1 2 3 4 5 6 
foreach var of varlist  D15_1 E15_1 D14_1 E14_1 D_total E_total{
logout, save(Table 3_`1') word replace:tab `var' 
macro shift
}

*****Table 4 Health care seeking behaviors of the participants at the first experience with care
tokenize 1 2 3 4 5 6 7 8 9 10
foreach var of varlist  D_recentyear1 E_recentyear1 D2_reshape E2_reshape D_wherefirst1 E_wherefirst1 D_afterday E_afterday D_delay E_delay{
logout, save(Table4_`1') word replace:tab `var' 
macro shift
}


***Table 5: Results of multivariate logistic regression analyses examining factors associated with regular clinic visits and medication adherence correlation analysis

***1.Outcome-Regularity: combine together
gen total_regular=0 
replace total_regular=1 if E_total==1|D_total==1
label var total_regular "Take medicine or see a doctor regularly last three months (1=yes)"
tab total_regular

***2.Duration:combine together
gen total_recentyear1=3 if E_recentyear1==3|D_recentyear1==3
replace total_recentyear1=2 if E_recentyear1==2 |D_recentyear1==2
replace total_recentyear1=1 if E_recentyear1==1 |D_recentyear1==1
tab total_recentyear1
label var total_recentyear1 "The duration of the chronic disease (1=within 5 years, 2=more than 5 years, 3=more than 10 years)"


***3.Whether see a doctor first: combine together
gen D_doctorfirst=0 if samplesize_h==1
replace D_doctorfirst=1 if samplesize_h==1&(D_wherefirst1==1|D_wherefirst1==2|D_wherefirst1==3|D_wherefirst1==4)
label var D_doctorfirst "whether see a doctor at first (H,1=yes)"

gen E_doctorfirst=0 if samplesize_d==1
replace E_doctorfirst=1 if samplesize_d==1&(E_wherefirst1==1|E_wherefirst1==2|E_wherefirst1==3|E_wherefirst1==4)
label var E_doctorfirst "whether see a doctor at first (D,1=yes)"

gen total_doctorfisrt=0
replace total_doctorfisrt=1 if D_doctorfirst==1|E_doctorfirst==1
tab total_doctorfisrt
label var total_doctorfisrt "Whether see a doctor at first (1=yes)"

recode gender(0=2)
recode poor_h(0=2)
recode total_doctorfisrt (0=2)

logit total_regular i.gender  i.age1 i.education i.health_sta  i.poor_h i.total_doctorfisrt i.total_recentyear1,or level(95)
logit total_regular i.gender  i.age1 i.education i.health_sta  i.poor_h i.total_doctorfisrt i.total_recentyear1

use "/Users/macbook/Desktop/Chronic disease/data& dofile/share_data of village clinics.dta",clear
logout, save(Table 6) word replace:tabstat tot_num_d num_visit pub_h2 pub_h3 vc_h2 vc_d2  vc_h3 vc_d3,stats(mean sd) c(s) f(%12.2fc) 
